
//Pressing enter will add a frame
private: System::Void Form1_KeyPress(System::Object *  sender, System::Windows::Forms::KeyPressEventArgs *  e)
		 {
			 if(e->KeyChar == Keys::Enter)
			 {
				 needsSave(true);
				 AddFrame_Click(NULL, NULL);
			 }
		 }

//when they select a new frame
private: System::Void FrameList_SelectedIndexChanged(System::Object *  sender, System::EventArgs *  e)
		 {
			 if(AniList->SelectedIndex < 0 || FrameList->SelectedIndex < 0)
				 return;

			 AnimObject *curAni = (AnimObject*)AniList->SelectedItem;
			 TGNAni *viewAni = curAni->GetAni();

			 FrameObject *newFrame = curAni->GetFrame(FrameList->SelectedIndex);
			 TGNFrame *viewFrame = newFrame->f;

			 selection.X   = viewFrame->x;
			 selection.Y    = viewFrame->y;
			 selection.Width  = viewFrame->w;
			 selection.Height = viewFrame->h;

			 hotx = viewFrame->hotx;
			 hoty = viewFrame->hoty;

			 bounds.X = selection.X + viewFrame->boundx;
			 bounds.Y = selection.Y + viewFrame->boundy;
			 bounds.Width = viewAni->boundW;
			 bounds.Height = viewAni->boundH;

			 frameDelay->Value = viewFrame->delay;

			 selection.X *= zoomLevel;
			 selection.Y *= zoomLevel;
			 selection.Width *= zoomLevel;
			 selection.Height *= zoomLevel;
			 hotx *= zoomLevel;
			 hoty *= zoomLevel;
			 bounds.X *= zoomLevel;
			 bounds.Y *= zoomLevel;
			 bounds.Width *= zoomLevel;
			 bounds.Height *= zoomLevel;

			 ImageBox->Invalidate();
		 }

//clicking add frame...
private: System::Void AddFrame_Click(System::Object *  sender, System::EventArgs *  e)
		 {
			 if(AniList->SelectedIndex < 0)
			 {
				 MessageBox::Show("Please select an animation first");
				 return;
			 }

			 if(selection.Left == -1 || selection.Top == -1)
			 {
				 MessageBox::Show("Please define a frame first.");
				 return;
			 }

			 FrameObject *newFrame = new FrameObject;
			 newFrame->f = new TGNFrame;

			 newFrame->f->x = selection.Left / zoomLevel;
			 newFrame->f->y = selection.Top / zoomLevel;
			 newFrame->f->w = selection.Width / zoomLevel;
			 newFrame->f->h = selection.Height / zoomLevel;
			 newFrame->f->delay = Decimal::ToInt32(frameDelay->Value);

			 AnimObject *curAni = (AnimObject*)AniList->SelectedItem;
			 int newIndex = curAni->AddFrame(newFrame);

			 FrameList->DataSource = NULL;
			 FrameList->DataSource = curAni->frames;

			 FrameList->SelectedIndex = newIndex;

			/*if(file->AddFrame(AniList->SelectedIndex, , , , , ))
			{
				int newIndex = 0;
				newIndex = FrameList->Items->Add(S"Frame");
				FrameList->SelectedIndex = newIndex;

			}*/

			 needsSave(true);
		 }

//right clicking on hte list
private: System::Void FrameList_MouseDown(System::Object *  sender, System::Windows::Forms::MouseEventArgs *  e)
		 {
			 if(e->Button == MouseButtons::Right)
			 {
				 Point pt(e->X, e->Y);

				 if(FrameList->IndexFromPoint(pt) >= 0)
					FrameList->SelectedIndex = FrameList->IndexFromPoint(pt);
			 }
		 }

//Update frame
private: System::Void UpdateFrame_Click(System::Object *  sender, System::EventArgs *  e)
		 {
			 if(AniList->SelectedIndex < 0)
			 {
				 MessageBox::Show("Please select an animation first");
				 return;
			 }

			 if(FrameList->SelectedIndex < 0)
			 {
				 MessageBox::Show("Please select a frame first");
				 return;
			 }

			 if(selection.Left == -1 || selection.Top == -1)
			 {
				 MessageBox::Show("Please define a frame first.");
				 return;
			 }

			 //AnimObject *curAni = (AnimObject*)AniList->SelectedItem;
			 FrameObject *newFrame = ((AnimObject*)AniList->SelectedItem)->GetFrame(FrameList->SelectedIndex);
			 TGNFrame *viewFrame = newFrame->f;

			 newFrame->f->x = selection.Left / zoomLevel;
			 newFrame->f->y = selection.Top / zoomLevel;
			 newFrame->f->w = selection.Width / zoomLevel;
			 newFrame->f->h = selection.Height / zoomLevel;
			 newFrame->f->delay = Decimal::ToInt32(frameDelay->Value);

			 needsSave(true);
		 }